package hbasecli.controller;

import hbasecli.config.ConnectionConfig;
import hbasecli.resp.Resp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import java.util.HashMap;
import java.util.Map;

import static hbasecli.resp.Resp.success;

@RestController
public class ConfigController {

    @Resource
    private ConnectionConfig connectionConfig;

    @GetMapping("/api/connectionConfig")
    public Resp<Map<String,String>> getConnectionConfig() {
        Map<String, String> map = new HashMap<>();
        map.put("hbase.zookeeper.property.clientPort", connectionConfig.getZookeeperPropertyClientPort());
        map.put("hbase.zookeeper.quorum", connectionConfig.getZookeeperQuorum());
        map.put("hbase.master.port", connectionConfig.getMasterPort());
        map.put("hbase.regionserver.port", connectionConfig.getRegionserverPort());
        return success(map);
    }
}
